<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>会议管理系统</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script
	src="${pageContext.request.contextPath}/plugin/js/jquery-3.2.1.min.js"></script>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugin/css/bootstrap.min.css">
<link
	href="${pageContext.request.contextPath}/plugin/css/font-awesome.min.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath}/plugin/css/animate.min.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath}/plugin/css/style.min.css"
	rel="stylesheet">
<!-- <base target="_blank"> -->
</head>
<body class="gray-bg">

	<div class="middle-box text-center loginscreen  animated fadeInDown">
		<div>
			<div>

				<h1 class="logo-name">SM</h1>

			</div>
			<h3>欢迎使用 SM</h3>

			<div class="m-t">
				<div class="form-group">
					<input type="text" class="form-control" placeholder="用户名"
						name="accountName" id="accountName">
				</div>
				<div class="form-group">
					<input type="password" class="form-control" placeholder="密码"
						name="accountPwd" id="accountPwd">
				</div>
				<button id="loginButton"
					class="btn btn-primary block full-width m-b">登 录</button>


				<p class="text-muted text-center">
					<a href="login.html#"><small>忘记密码了？</small></a> | <a
						href="register.html">注册一个新账号</a>
				</p>
				<p class="text-muted text-center"> <a href="${pageContext.request.contextPath}/main.jsp"><small>欢迎页面</small></a>
				</p>
			</div>
		</div>
		<script type="text/javascript">
			$("#loginButton")
					.click(
							function() {
								var accountName = $("#accountName").val();
					        	var accountPwd = $("#accountPwd").val();
								var account = {"accountName":accountName,"accountPwd":accountPwd}; 
					        	if (accountName == '') {
									alert("用户名不为空");
									
								} else if (accountPwd == '') {
									alert("密码不为空");
									
								} else {

									$.ajax({
												type : "POST",
												url : "${pageContext.request.contextPath}/logon",
												dataType : "json",
												contentType : "application/json; charset=utf-8",
												data : JSON.stringify(account),
												success : function(datas) {

													if (515 == datas.state) {
														alert("密码错误");
													} else if (513 == datas.state) {
														alert("用户不存在");
													} else if (516 == datas.state) {
														alert("初次登陆，跳转中.....");
														window.location.href = "${pageContext.request.contextPath}/reset";
													} else if (517 == datas.state) {
														alert("非初次登陆，跳转中....");
														window.location.href = "${pageContext.request.contextPath}/main.jsp";
													}
												}
											});
								}
							})
		</script>
	</div>
</body>



</html>
